<!DOCTYPE html>
<html lang="en">
	<head>
	    <meta charset="UTF-8">
	    <script type="text/javascript" src="../assets/js/vue.js" ></script>
	    <title>computed</title>
	</head>
	<body>
		<h1>computed</h1>
		<div id="app">
			{{price}}
			{{newPrice}}
			<ul>
				<li v-for='item in newsList'>{{item}}</li>
			</ul>
			<hr />
			<ul>
				<li v-for='item in newNewsList'>{{item}}</li>
			</ul>			
		</div>
	</body>
	
	<script type="application/javascript">
		var newsList = [
			{title:'测试1',date:'2019年4月7日'},
			{title:'测试2',date:'2018年4月7日'},
			{title:'测试3',date:'2016年4月7日'},
			{title:'测试4',date:'2015年4月7日'}
		]
	
		var app = new Vue({
			el:'#app',
			data:{
				message:'Hello World',
				price:100,
				newsList : newsList
			},
			computed:{
				newPrice:function(){
					return '$' + this.price + '.00'
				},
				newNewsList:function(){
					return this.newsList.reverse();
				}
			}
		})
	</script>
</html>